package com.itheima.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.itheima.dao.SetmealDishDao;
import com.itheima.entity.SetmealDish;
import com.itheima.service.SetmealDishService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SetmealDishServiceImpl implements SetmealDishService {

    @Autowired
    private SetmealDishDao setmealDishDao;









    @Override
    public void add(SetmealDish setmealDish) {


        setmealDishDao.insert(setmealDish);

    }

    @Override
    public List<SetmealDish> updateById(Long setmealId) {

        LambdaQueryWrapper<SetmealDish> lqw = new LambdaQueryWrapper<>();
        lqw.eq(SetmealDish::getSetmealId,setmealId);
        List<SetmealDish> setmealDishes = setmealDishDao.selectList(lqw);
        return setmealDishes;
    }

    @Override
    public Integer delete(Long setmealId) {
        LambdaQueryWrapper<SetmealDish> lqw = new LambdaQueryWrapper<>();
        lqw.eq(SetmealDish::getSetmealId,setmealId);


        return  setmealDishDao.delete(lqw);
    }


}
